<template>
    <div>
        <NavBar :title="title"></NavBar>
        <div v-html="detailApiData.goods_introduce"></div>
        <van-action-bar>
            <van-action-bar-icon icon="chat-o" text="客服" color="#ee0a24" />
            <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
            <van-action-bar-icon icon="star" text="已收藏" color="#ff5000" />
            <van-action-bar-button type="warning" text="加入购物车" @click="gwc" />
            <van-action-bar-button type="danger" text="立即购买" />
        </van-action-bar>

    </div>
</template>

<script setup>
import NavBar from '@/components/NavBar.vue';
const title = '商品详情'
import { ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const router = useRouter()
const route = useRoute()
console.log(route.params.goods_id);
const detailApiData = ref([])
import { detailApi } from '@/api/api';
detailApi(route.params.goods_id).then(res => {
    console.log(res);
    detailApiData.value = res.data.message
})
import { useCounterStore } from '@/stores/counter'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
const gwc = () => {
    store.counterAdd(detailApiData.value, route.params.goods_id)
    router.push('/home/gwc')
}
</script>

<style lang="scss" scoped></style>